using System;
using System.Data;
using Wicresoft.Common;
namespace MonthlyDB.Entity
{
	[Table("Attachment", "", "Monthly.ConnectionString")]
	[Serializable]
	public class Attachment : Info
	{
        #region SQL column name consts
        public const string SQLCOL_ID = "ID";
        public const string SQLCOL_DISPLAYNAME = "DisplayName";
        public const string SQLCOL_PHYSICALPATH = "PhysicalPath";
        public const string SQLCOL_PHYSICALURL = "PhysicalUrl";
        public const string SQLCOL_CONTENTLENGTH = "ContentLength";
        public const string SQLCOL_UPLOADTIME = "UploadTime";
        public const string SQLCOL_MONTHLYID = "MonthlyID";
        #endregion


        #region Contructors
        /// <summary>
        /// Construct empty entity
        /// </summary>
        public Attachment() { }

        /// <summary>
        /// Construct entity by primary key, other fields will be assigned by 
        /// "Load" method.
        /// </summary>
        public Attachment(Guid ID)
        {
            this.ID = ID;
        }
        #endregion

        public override void Init(DataRow row)
        {
            ID = (Guid)ObjectType.GuidTypeHelper.Read(row[SQLCOL_ID]);
            DisplayName = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_DISPLAYNAME]);
            PhysicalPath = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_PHYSICALPATH]);
            PhysicalUrl = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_PHYSICALURL]);
            ContentLength = (int)ObjectType.IntTypeHelper.Read(row[SQLCOL_CONTENTLENGTH]);
            UploadTime = (DateTime)ObjectType.DateTimeTypeHelper.Read(row[SQLCOL_UPLOADTIME]);
            MonthlyID = (Guid)ObjectType.GuidTypeHelper.Read(row[SQLCOL_MONTHLYID]);
        }

        #region Properties
        #region Property <Guid> ID
        [Property("ID", 16, SqlDbType.UniqueIdentifier, false, true)]
        public Guid ID
        {
            get { return _ID; }
            set { _ID = value; }
        }
        private Guid _ID = Guid.Empty;
        #endregion

        #region Property <string> DisplayName
        [Property("DisplayName", 200, SqlDbType.NVarChar, false, false)]
        public string DisplayName
        {
            get { return _DisplayName; }
            set { _DisplayName = value; }
        }
        private string _DisplayName = null;
        #endregion

        #region Property <string> PhysicalPath
        [Property("PhysicalPath", 200, SqlDbType.NVarChar, false, false)]
        public string PhysicalPath
        {
            get { return _PhysicalPath; }
            set { _PhysicalPath = value; }
        }
        private string _PhysicalPath = null;
        #endregion

        #region Property <string> PhysicalUrl
        [Property("PhysicalUrl", 200, SqlDbType.NVarChar, false, false)]
        public string PhysicalUrl
        {
            get { return _PhysicalUrl; }
            set { _PhysicalUrl = value; }
        }
        private string _PhysicalUrl = null;
        #endregion

        #region Property <int> ContentLength
        [Property("ContentLength", 4, SqlDbType.Int, false, false)]
        public int ContentLength
        {
            get { return _ContentLength; }
            set { _ContentLength = value; }
        }
        private int _ContentLength = int.MinValue;
        #endregion

        #region Property <DateTime> UploadTime
        [Property("UploadTime", 16, SqlDbType.DateTime, false, false)]
        public DateTime UploadTime
        {
            get { return _UploadTime; }
            set { _UploadTime = value; }
        }
        private DateTime _UploadTime = DateTime.MinValue;
        #endregion

        #region Property <Guid> MonthlyID
        [Property("MonthlyID", 16, SqlDbType.UniqueIdentifier, false, false)]
        public Guid MonthlyID
        {
            get { return _MonthlyID; }
            set { _MonthlyID = value; }
        }
        private Guid _MonthlyID = Guid.Empty;
        #endregion
        #endregion
	}
}
